﻿using System;
using System.Collections;
using UnityEngine;
using UnityEngine.Events;

namespace Valve.VR.InteractionSystem
{
	// Token: 0x0200063B RID: 1595
	public class ArcheryTarget : MonoBehaviour
	{
		// Token: 0x06002884 RID: 10372 RVA: 0x000EB604 File Offset: 0x000E9804
		private void ApplyDamage()
		{
			this.OnDamageTaken();
		}

		// Token: 0x06002885 RID: 10373 RVA: 0x000EB60C File Offset: 0x000E980C
		private void FireExposure()
		{
			this.OnDamageTaken();
		}

		// Token: 0x06002886 RID: 10374 RVA: 0x000EB614 File Offset: 0x000E9814
		private void OnDamageTaken()
		{
			if (this.targetEnabled)
			{
				this.onTakeDamage.Invoke();
				base.StartCoroutine(this.FallDown());
				if (this.onceOnly)
				{
					this.targetEnabled = false;
				}
			}
		}

		// Token: 0x06002887 RID: 10375 RVA: 0x000EB64C File Offset: 0x000E984C
		private IEnumerator FallDown()
		{
			if (this.baseTransform)
			{
				Quaternion startingRot = this.baseTransform.rotation;
				float startTime = Time.time;
				float rotLerp = 0f;
				while (rotLerp < 1f)
				{
					rotLerp = Util.RemapNumberClamped(Time.time, startTime, startTime + this.fallTime, 0f, 1f);
					this.baseTransform.rotation = Quaternion.Lerp(startingRot, this.fallenDownTransform.rotation, rotLerp);
					yield return null;
				}
			}
			yield return null;
			yield break;
		}

		// Token: 0x0400285D RID: 10333
		public UnityEvent onTakeDamage;

		// Token: 0x0400285E RID: 10334
		public bool onceOnly;

		// Token: 0x0400285F RID: 10335
		public Transform targetCenter;

		// Token: 0x04002860 RID: 10336
		public Transform baseTransform;

		// Token: 0x04002861 RID: 10337
		public Transform fallenDownTransform;

		// Token: 0x04002862 RID: 10338
		public float fallTime = 0.5f;

		// Token: 0x04002863 RID: 10339
		private const float targetRadius = 0.25f;

		// Token: 0x04002864 RID: 10340
		private bool targetEnabled = true;
	}
}
